package com.kuang.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kuang.entity.Ticket;
import com.kuang.mapper.TicketMapper;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TicketServiceImpl extends ServiceImpl<TicketMapper, Ticket> implements TicketService {

    /**
     * 根据产品ID查询门票信息
     * @param productId
     * @param cid
     * @return
     */
    @Override
    public List<Ticket> findTicketByProductId(Long productId, Integer cid) {
        LambdaQueryWrapper<Ticket> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(Ticket::getProductId, productId);
        lambdaQueryWrapper.eq(Ticket::getStatus, 1);
        lambdaQueryWrapper.eq(Ticket::getCid, cid);
        lambdaQueryWrapper.orderByDesc(Ticket::getCreateTime);
        List<Ticket> ticketList = this.list(lambdaQueryWrapper);
        return ticketList;
    }
}
